home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / BBS-Archive / Comm / AmiTCP30b2.lha / src / rpclib / auth_none.c next >
C/C++ Source or Header  |  1994-03-09  |  4KB  |  145 lines

  1. /*
  2.  * $Id: auth_none.c,v 1.3 1994/02/25 00:21:41 jraja Exp $
  3.  *
  4.  * $Log: auth_none.c,v $
  5.  * Revision 1.3  1994/02/25  00:21:41  jraja
  6.  * Changed malloc, calloc and free to mem_alloc, mem_calloc and mem_free,
  7.  * respectively.
  8.  *
  9.  * Revision 1.2  1993/11/10  01:14:30  jraja
  10.  * ANSI prototypes.
  11.  *
  12.  */
  13. /* @(#)auth_none.c    2.1 88/07/29 4.0 RPCSRC */
  14. /*
  15.  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  16.  * unrestricted use provided that this legend is included on all tape
  17.  * media and as a part of the software program in whole or part.  Users
  18.  * may copy or modify Sun RPC without charge, but are not authorized
  19.  * to license or distribute it to anyone else except as part of a product or
  20.  * program developed by the user.
  21.  * 
  22.  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  23.  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  24.  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  25.  * 
  26.  * Sun RPC is provided with no support and without any obligation on the
  27.  * part of Sun Microsystems, Inc. to assist in its use, correction,
  28.  * modification or enhancement.
  29.  * 
  30.  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  31.  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  32.  * OR ANY PART THEREOF.
  33.  * 
  34.  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  35.  * or profits or other special, indirect and consequential damages, even if
  36.  * Sun has been advised of the possibility of such damages.
  37.  * 
  38.  * Sun Microsystems, Inc.
  39.  * 2550 Garcia Avenue
  40.  * Mountain View, California  94043
  41.  */
  42. #if !defined(lint) && defined(SCCSIDS)
  43. static char sccsid[] = "@(#)auth_none.c 1.19 87/08/11 Copyr 1984 Sun Micro";
  44. #endif
  45.  
  46. /*
  47.  * auth_none.c
  48.  * Creates a client authentication handle for passing "null" 
  49.  * credentials and verifiers to remote systems. 
  50.  * 
  51.  * Copyright (C) 1984, Sun Microsystems, Inc. 
  52.  */
  53.  
  54. #include <sys/param.h>
  55. #include <rpc/types.h>
  56. #include <rpc/xdr.h>
  57. #include <rpc/auth.h>
  58. #define MAX_MARSHEL_SIZE 20
  59.  
  60. /*
  61.  * Authenticator operations routines
  62.  */
  63. static void    authnone_verf(AUTH *);
  64. static bool_t    authnone_marshal(AUTH * client, XDR * xdrs);
  65. static bool_t    authnone_validate(AUTH *, struct opaque_auth *);
  66. static bool_t    authnone_refresh(AUTH *);
  67. static void    authnone_destroy(AUTH *);
  68.  
  69. static struct auth_ops ops = {
  70.     authnone_verf,
  71.     authnone_marshal,
  72.     authnone_validate,
  73.     authnone_refresh,
  74.     authnone_destroy
  75. };
  76.  
  77. static struct authnone_private {
  78.     AUTH    no_client;
  79.     char    marshalled_client[MAX_MARSHEL_SIZE];
  80.     u_int    mcnt;
  81. } *authnone_private;
  82.  
  83. AUTH *
  84. authnone_create()
  85. {
  86.     register struct authnone_private *ap = authnone_private;
  87.     XDR xdr_stream;
  88.     register XDR *xdrs;
  89.  
  90.     if (ap == 0) {
  91.         ap = (struct authnone_private *)mem_calloc(1, sizeof (*ap));
  92.         if (ap == 0)
  93.             return (0);
  94.         authnone_private = ap;
  95.     }
  96.     if (!ap->mcnt) {
  97.         ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth;
  98.         ap->no_client.ah_ops = &ops;
  99.         xdrs = &xdr_stream;
  100.         xdrmem_create(xdrs, ap->marshalled_client, (u_int)MAX_MARSHEL_SIZE,
  101.             XDR_ENCODE);
  102.         (void)xdr_opaque_auth(xdrs, &ap->no_client.ah_cred);
  103.         (void)xdr_opaque_auth(xdrs, &ap->no_client.ah_verf);
  104.         ap->mcnt = XDR_GETPOS(xdrs);
  105.         XDR_DESTROY(xdrs);
  106.     }
  107.     return (&ap->no_client);
  108. }
  109.  
  110. /*ARGSUSED*/
  111. static bool_t
  112. authnone_marshal(client, xdrs)
  113.     AUTH *client;
  114.     XDR *xdrs;
  115. {
  116.     register struct authnone_private *ap = authnone_private;
  117.  
  118.     if (ap == 0)
  119.         return (0);
  120.     return ((*xdrs->x_ops->x_putbytes)(xdrs,
  121.         ap->marshalled_client, ap->mcnt));
  122. }
  123.  
  124. static void 
  125. authnone_verf(AUTH *client)
  126. {
  127. }
  128.  
  129. static bool_t
  130. authnone_validate(AUTH *client, struct opaque_auth *verfp)
  131. {
  132.     return (TRUE);
  133. }
  134.  
  135. static bool_t
  136. authnone_refresh(AUTH * client)
  137. {
  138.     return (FALSE);
  139. }
  140.  
  141. static void
  142. authnone_destroy(AUTH * client)
  143. {
  144. }
  145.